import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import cart from '@/components/cart'
import item from '@/components/item'
import detail from '@/components/detail'
import mytest from '@/components/mytest'
import test from '@/components/test'
import reg from '@/components/reg'
import login from '@/components/login'
import myprofile from '@/components/myprofile'
import addgoods from '@/components/addgoods'
import editgood from '@/components/editgood'
import search from '@/components/search'


import qiniu from '@/components1/qiniu'
import Login2 from "../components1/Login2";
import addgos from "../components1/addgos";
import goodslist from "../components1/goodslist";
import uidflows from "../components1/uidflows";



Vue.use(Router)

var routes = [
        {
          path:'/',
          name:'index',
          component:index
        },
        {
          path:'/cart',
          name:'cart',
          component:cart
        },
        {
          path:'/item',
          name:'item',
          component:item
        },
        {
          path:'/detail',
          name:'detail',
          component:detail
        },
        {
          path:'/mytest',
          name:'mytest',
          component:mytest
        },
        {
          path:'/test',
          name:'test',
          component:test
        },
        {
          path:'/reg',
          name:'reg',
          component:reg
        },
        {
          path:'/login',
          name:'login',
          component:login
        },
        {
          path:'/addgoods',
          name:'addgoods',
          component:addgoods
        },
        {
          path:'/editgood',
          name:'editgood',
          component:editgood
        },
        {
          path:'/search',
          name:'search',
          component:search
        },

        {
          path:'/myprofile',
          name:'myprofile',
          component:myprofile,

          //拦截器的使用
          beforeEnter:(to, from, next)=>{
            //判断用户是否登录
            if(localStorage.getItem("username")){
              console.log('已登录');
              next();
            }else {
              console.log('未登录');
              next('/login');
            }
          }
        },




        {
          path:'/qiniu',
          name:'qiniu',
          component:qiniu
        },
        {
          path:'/login2',
          name:'login2',
          component:Login2
        },
        {
          path:'/addgos',
          name:'addgos',
          component:addgos
        },
        {
          path:'/goodslist',
          name:'goodslist',
          component:goodslist
        },
        {
          path:'/uidflows',
          name:'uidflows',
          component:uidflows
        },



]

export default new Router({
  routes:routes,
  mode:'history'   /*hash*/
})
